<template>
  <div>
    <!--顶部区域-->
    <!--面包屑导航-->
    <Breadcrumb></Breadcrumb>
    <div class="header">
      <div class="form">
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
          <el-form-item label="预定编号">
            <el-input
              v-model="formInline.name"
              placeholder="预定编号"
              size="small"
            ></el-input>
          </el-form-item>
          <el-form-item label="预定时间">
            <el-date-picker
              v-model="formInline.date"
              type="date"
              placeholder="选择日期"
              size="small"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" size="small">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="group">
        <el-button type="warning" size="small">导出</el-button>
      </div>
    </div>
    <!--表格-->
    <div class="content">
      <el-table
        :data="tableData"
        border
        stripe
        style="width: 100%"
        header-row-class-name="active-header"
        cell-class-name="table-center"
      >
        <el-table-column type="selection" width="55" header-align="center">
        </el-table-column>
        <el-table-column
          prop="orderNum"
          label="汇总单编号"
          header-align="center"
        >
        </el-table-column>
        <el-table-column prop="operator" label="汇总人" header-align="center">
        </el-table-column>
        <el-table-column prop="phone" label="联系电话" header-align="center">
        </el-table-column>
        <el-table-column prop="time" label="汇总时间" header-align="center">
          <template slot-scope="scope">
            {{ dayjs(scope.row.time).format("YYYY-MM-DD HH:mm:ss") }}
          </template>
        </el-table-column>
        <el-table-column
          prop="totalPrice"
          label="汇总单总价格"
          header-align="center"
        >
        </el-table-column>
        <el-table-column label="操作" header-align="center">
          <template slot-scope="scope">
            <el-button size="mini" type="danger" @click="handleEdit(scope.row)"
              >撤销汇总</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <Pagination
        :total="total"
        :pageSize="pageSize"
        @CurrentChange="CurrentChange"
      ></Pagination>
    </div>
  </div>
</template>
  
  <script>
import dayjs from "dayjs";
import Pagination from "@/components/pagination/Pagination.vue";

export default {
  components: {
    Pagination,
  },
  data() {
    return {
      formInline: {},
      tableData: [],
      total: 10,
      pageSize: 1,
    };
  },

  created() {
    this.collect(1);
  },
  methods: {
    dayjs,
    //获取分页
    CurrentChange() {},
    //撤销汇总
    handleEdit(row) {
      //获取当前行id
      this.$api.cancel({ id: row.id }).then((res) => {
        console.log(res.data);
        if (res.data.status == 200) {
          //更新视图
          this.collect(1);
        }
      });
    },
    //获取汇总清单列表
    async collect(page) {
      let res = await this.$api.collect({ page });
      console.log("汇总清单列表----", res.data);
      if (res.status == 200) {
        this.tableData = res.data.data;
        this.total = res.data.total;
        this.pageSize = res.data.pageSize;
      } else {
        (this.tableData = []), (this.total = 0);
        this.pageSize = 0;
      }
    },
  },
};
</script>
  
  <style lang="less" scoped>
.header {
  background: #fff;
  margin-bottom: 20px;
  padding: 10px;
  .el-form-item {
    margin-bottom: 10px;
  }
  .group {
    border: 1px solid #eee;
    padding: 5px;
  }
}
.content {
  background: #fff;
  /deep/ .active-header {
    text-align: center;
    color: #333;
  }

  /deep/ .table-center {
    text-align: center;
  }
}
</style>